<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>钱包</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <style>
        body {
            background: #fff;
            font-size: 14px;
            overflow-x: hidden;
        }

        .money {
            color:#000;
            font-size:18px;
        }

        .title {
            width: 100%;
            display: block;
        }

        .time {
            color: #9c9c9c;
        }

        .shouru li {
            position: relative;
            padding:10px 7px;
            color: #666;
        }

        .shouru li:before {
            border-bottom: 1px solid #9c9c9c;
            -webkit-transform: scale(0.5);
            position: absolute;
            bottom: 0;
            content: "";
            left: -100%;
            right: -100%;
        }

        .tixian {
            display: none;
        }

        .tixian li {
            position: relative;
            padding: 6px 0px;
        }

        .tixian li:before {
            border-bottom: 1px solid #9c9c9c;
            -webkit-transform: scale(0.5);
            position: absolute;
            bottom: 0;
            content: "";
            left: -100%;
            right: -100%;
        }
        .contain,.shouru,.list-content{
            overflow: hidden;
        }
    </style>
</head>
<body>
<div class=" contain aui-content-padded">
    <div class="shouru">
        <ul id="list-content">
            <!-- data-type标识是否提现 2为提现-->
            <!--<li tapmode data-type="1" onclick="openInfo(this)">-->
                <!--<span class="money aui-pull-left">+368.25</span>-->
                <!--<span class=" aui-pull-right active">等待卖家发货</span>-->
                <!--<span class="title aui-ellipsis-1">女式休闲裤修身直筒女式时尚拉链口袋五分裤女式休闲裤修身直筒女式时尚拉链口袋五分裤</span>-->
                <!--<span class="time">2016-10-31 15:22:27</span>-->
            <!--</li>-->
            <!--<li tapmode data-type="1" onclick="openInfo(this)">-->
                <!--<span class="money aui-pull-left">+368.25</span>-->
                <!--<span class=" aui-pull-right active">等待卖家发货</span>-->
                <!--<span class="title aui-ellipsis-1">女式休闲裤修身直筒女式时尚拉链口袋五分裤女式休闲裤修身直筒女式时尚拉链口袋五分裤</span>-->
                <!--<span class="time">2016-10-31 15:22:27</span>-->
            <!--</li>-->
            <!--<li tapmode data-type="1" onclick="openInfo(this)">-->
                <!--<span class="money aui-pull-left">+368.25</span>-->
                <!--<span class=" aui-pull-right active">等待卖家发货</span>-->
                <!--<span class="title aui-ellipsis-1">女式休闲裤修身直筒女式时尚拉链口袋五分裤女式休闲裤修身直筒女式时尚拉链口袋五分裤</span>-->
                <!--<span class="time">2016-10-31 15:22:27</span>-->
            <!--</li>-->
            <!--<li tapmode data-type="1" onclick="openInfo(this)">-->
                <!--<span class="money aui-pull-left">+368.25</span>-->
                <!--<span class=" aui-pull-right ">交易关闭</span>-->
                <!--<span class="title aui-ellipsis-1">女式休闲裤修身直筒女式时尚拉链口袋五分裤女式休闲裤修身直筒女式时尚拉链口袋五分裤</span>-->
                <!--<span class="time">2016-10-31 15:22:27</span>-->
            <!--</li>-->
        </ul>
    </div>
</div>
<script id="incomeList-template" type="x-dot-template">
    {{ for (var i in it) { }}
    <li tapmode data-type='1' data-id='{{=it[i].order_id}}' onclick='openInfo(this)'>
        <span class="money aui-pull-left">+{{=it[i].order_amount}}</span>
        <span class="aui-pull-right active">
            {{? it[i].status == 0}}交易关闭
            {{?? it[i].status == 1}}等待买家付款
            {{?? it[i].status == 2}}买家已付款
            {{?? it[i].status == 3}}卖家已发货
            {{?? it[i].status == 4}}交易成功
            {{?? it[i].status == 5}}已评价
            {{?? it[i].status == 6}}申请退款
            {{?? it[i].status == 7}}申请退货
            {{?}}
        </span>
        <span class="title aui-ellipsis-1" style="padding:7px 0;">
            {{=it[i].goods[0].title}}
        </span>
        <span class="time">{{=it[i].addtime}}</span>
    </li>
    {{ } }}
</script>
<script id="depositList-template" type="x-dot-template">
    {{ for (var i in it) { }}
    <li tapmode data-type="2" data-id="{{=it[i].itemid}}" onclick="openInfo(this)">
        <span class="money aui-pull-left">-{{=it[i].amount}}</span>
        <span class=" aui-pull-right active">
            {{? it[i].status == 0}}
            等待受理
            {{?? it[i].status == 1}}
            拒绝申请
            {{?? it[i].status == 2}}
            提现失败
            {{?? it[i].status == 3}}
            提现成功
            {{?}}
        </span>
        <span class="title aui-ellipsis-1" style="padding:7px 0;">申请提现</span>
        <span class="time"></span>
    </li>
    {{ } }}
</script>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/echo.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/myInfo.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript">
    var page = 1, isLock = false, type = 1;
    apiready = function () {
        api.parseTapmode();
        //第二个页面,接收监听--有跨页面传参数
        api.addEventListener({
            name: 'moneyListType'
        }, function (ret) {
            if (ret && ret.value) {
                $("#list-content").empty();
                isLock=false;
                page = 1;
                type = ret.value.type;
                api.refreshHeaderLoading();
                return false;
            }
        });
        api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/ptr_pull.png',
            bgColor: '#efeff4',
            textColor: '#959595',
            textDown: '下拉刷新',
            textUp: '松开刷新',
            showTime: true
        }, function (ret, err) {
            isLock=false;
            page = 1;
            if (type == 1) {
                orderListSupplier();
            } else {
                depositLog();
            }
        });
        //监听是否达到底部上拉加载
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (isLock == false) {
                if (type == 1) {
                    orderListSupplier();
                } else {
                    depositLog();
                }
            }
        })
        getStorageAll();
        api.refreshHeaderLoading();
    }

    function openInfo(obj) {
        var type = $(obj).attr("data-type");
        var myOrderId=$(obj).attr("data-id");
        api.openWin({
            name: "walletInfo",
            url: "walletInfo.html",
            pageParam: {
                type: type,
                orderId:myOrderId
            }
        })
    }

    //收入明细
    function orderListSupplier(toPage) {
        if(isLock)return;

        toPage=toPage?toPage:page;
        if(toPage==1)api.refreshHeaderLoading();

        var data = {
            status: 0,
            userName: user_name,
            page: toPage,
        };
        var url = 'User/orderListSupplier';
        ajaxRequest(url, 'post', data, function (ret, err) {
            isLock = false;
            api.refreshHeaderLoadDone();
            if (ret.status == 1) {
                var content = $api.byId('list-content');
                var tpl = $api.byId('incomeList-template').text;
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    if(!$.trim(ret.msg)){
                        isLock=true;
                        return;
                    }
                    $api.append(content, tempFn(ret.msg));
                } else {
                    $api.html(content, tempFn(ret.msg));
                }


                $(".shouru").find(".time").each(function () {
                    $(this).text(stampToTime($(this).text()))

                })
            } else {
                if (page == 1) {
                    $("#list-content").empty();
                }
                api.toast({
                    msg: '已经加载完',
                    duration: 2000,
                    location: 'bottom'
                });
                isLock = true;
            }
        });
    }

    //提现明细
    function depositLog(toPage) {
        if(isLock)return;

        toPage=toPage?toPage:page;
        if(toPage==1)api.refreshHeaderLoading();

        var data = {
            userName: user_name,
            page: toPage,
        };
        var url = 'User/depositLog';
        ajaxRequest(url, 'post', data, function (ret, err) {
            isLock = false;
            api.refreshHeaderLoadDone();
            if (ret.status == 1) {
//                alert(JSON.stringify(ret));
                var content = $api.byId('list-content');
                var tpl = $api.byId('depositList-template').text;
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    $api.append(content, tempFn(ret.msg));
                } else {
                    $api.html(content, tempFn(ret.msg));
                }
                $(".shouru").find(".time").each(function () {
                    $(this).text(stampToTime($(this).text()))

                })
            } else {
                if (page == 1) {
                    $("#list-content").empty();
                }
                api.toast({
                    msg: '已经加载完',
                    duration: 2000,
                    location: 'bottom'
                });
                isLock = true;
            }
        });
    }
</script>
</html>